#include"comm.hpp"

int main(){
    int k = getkey();

    int shmid = getshm(k);
    printf("shmid:%d\n",shmid);

    char* s = (char*)attachshm(shmid);//初始地址
    printf("挂接成功，初始地址为:%p\n",s);


    //开始通信：客户端写数据
    char buffer[1024];
    const char* arr = "我是另一个进程，正在和你通信";
    int cnt = 0;
    while(true){
        sleep(1);
        snprintf(s,MAX_SIZE,"%s,pid:%d,cnt:%d\n",arr,getpid(),cnt++);
    }





    unlink_shm(s);


    return 0;
}